<?php
//网站设置（三屏）
namespace Home\Controller;
use Think\Controller;
class WebsiteController extends CommonController {
	
    public function index(){		
   		$this->redirect("basicSetup");
    }
	//基本设置
    public function basicSetup(){

        //获取套餐
        $basicSetup=M("basicSetup")->select();

        $this->assign("basicSetup",$basicSetup);

		$this->display();
    }


    //基本设置-提交表单
    public function basicSetupForm(){
     
       $map=I("post.");
        
        if(!$map){
            $this->error("","websiteService");
            exit;
        }

        $websiteModel=M("website_order");
        
        
        //验证表单重复提交
        $autoCheckToken=$websiteModel->autoCheckToken($map);
        if (!$autoCheckToken){
            $this->error("表单重复提交","basicSetup");
            exit;
        }

        
        //上传图片
        $website_img=uploadPhotos($_FILES,"website");

        $data=array(
            "user_id"=>$_SESSION["user"]["id"],
            "package_id"=>$map["websitePackage"],
            "website_content"=>$map["content"],
            "website_img"=>$website_img["mess"],
            "add_time"=>date("Y-m-d H:i:s")
         );   

        $websiteModel->startTrans();
        
        $res=$websiteModel->add($data);

        //数据顺利插入以及图片上传成功
        if($res!==false && $website_img["code"]=="200"){

            $websiteModel->commit();
            $this->success("","websiteList");

        }else{          

            $websiteModel->rollback();
            $this->error("","websiteService");
        }
    }

    //域名设置
    public function domainSteup(){
        
        $this->display();
    }

    //模块选择
    public function modelChoice(){
        
        $this->display();
    }

}